package com.wrx.server.controller;


import com.wrx.server.pojo.CommonBean;
import com.wrx.server.pojo.PageBean;
import com.wrx.server.pojo.RespBean;
import com.wrx.server.pojo.ThemePost;
import com.wrx.server.service.IThemePostService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  主题帖控制器
 * </p>
 *
 * @author wrx
 * @since 2021-04-20
 */
@RestController
public class ThemePostController{

    @Autowired
    private IThemePostService themePostService;

    /**
     * 发帖主题帖
     * @param themePost
     * @param request
     * @return
     */
    @ApiOperation(value = "发帖主题帖")
    @PostMapping("/ThemePost/publish-theme-post")
    public RespBean publishThemePost(@RequestBody ThemePost themePost, HttpServletRequest request) {
        return themePostService.setThemePost(themePost.getBar_id(), themePost.getTheme_post_title(), themePost.getTheme_post_info(), request);
    }

    @ApiOperation(value = "分页输出对应贴吧主题帖")
    @PostMapping("/ThemePost/put-page-theme-post")
    public RespBean putPageThemePost(@RequestBody PageBean pageBean) {
        return themePostService.putPageTheme(pageBean.getNum1(),pageBean.getPageNum(), pageBean.getPageSize(),pageBean.getState());
    }

    @ApiOperation(value = "查询一条主题帖信息")
    @PostMapping("/ThemePost/sel-one-theme-post")
    public RespBean selOneThemePost(@RequestBody CommonBean commonBean) {
        return themePostService.selOneThemePost(commonBean.getId());
    }

    @ApiOperation(value = "查询一条主题帖信息和用户昵称")
    @PostMapping("/ThemePost/sel-one-theme-post-and-netname")
    public RespBean selOneThemePostAndNetNameByThemePostId(@RequestBody CommonBean commonBean) {
        return themePostService.selOneThemePostAndNetNameByThemePostId(commonBean.getId());
    }


    @ApiOperation(value = "查询一条主题帖信息和用户昵称判断是否收藏")
    @PostMapping("/ThemePost/sel-one-themepost-netname-collectorstate")
    public RespBean selOneThemePostNetNameCollectorStateByThemePostId(@RequestBody CommonBean commonBean,HttpServletRequest request) {
        return themePostService.selOneThemePostNetNameCollectorStateByThemePostId(commonBean.getId(),request);
    }



}
